# MySQL Installation Script
Write-Host "Installing MySQL..." -ForegroundColor Green

# Install MySQL using Chocolatey
Write-Host "Installing MySQL with Chocolatey..." -ForegroundColor Yellow
choco install mysql -y

# Start MySQL service
Write-Host "Starting MySQL service..." -ForegroundColor Yellow
Start-Service mysql

# Wait for service to start
Start-Sleep -Seconds 5

# Set root password
Write-Host "Setting MySQL root password..." -ForegroundColor Yellow
mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123';"

# Create databases
Write-Host "Creating databases..." -ForegroundColor Yellow
mysql -u root -proot123 -e "CREATE DATABASE IF NOT EXISTS microservices;"
mysql -u root -proot123 -e "CREATE DATABASE IF NOT EXISTS microservices_user;"
mysql -u root -proot123 -e "CREATE DATABASE IF NOT EXISTS microservices_miniprogram;"
mysql -u root -proot123 -e "CREATE DATABASE IF NOT EXISTS microservices_h5;"
mysql -u root -proot123 -e "CREATE DATABASE IF NOT EXISTS microservices_config;"
mysql -u root -proot123 -e "CREATE DATABASE IF NOT EXISTS nacos_config;"

Write-Host "MySQL installation completed!" -ForegroundColor Green
Write-Host "Connection info:" -ForegroundColor Cyan
Write-Host "Host: localhost" -ForegroundColor White
Write-Host "Port: 3306" -ForegroundColor White
Write-Host "Username: root" -ForegroundColor White
Write-Host "Password: root123" -ForegroundColor White
